import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'
const TemplateKey = 'TemplateKey'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setTemplateBody(data) {
  let x= {}
  for (let i = 0; i < data.length; i++) {
    x[data[i].oid] = data[i].name
  }
  return localStorage.setItem(TemplateKey, JSON.stringify(x))
}

export function getTemplateBody() {
  return JSON.parse(localStorage.getItem(TemplateKey))
}

export function removeTemplateBody() {
  return localStorage.removeItem(TemplateKey)
}
